/**
 * @import { RspackPluginInstance } from "@rspack/core";
 */

/**
 * @class
 * @implements {RspackPluginInstance}
 */
class DepLayerPlugin {
  /**
   * @private
   */
  compileCounter = 0;

  /**
   * @param {import('@rspack/core').Compiler} compiler
   */
  apply(compiler) {
    compiler.hooks.beforeCompile.tap("DonePlugin", (params) => {
      this.compileCounter++;
      console.time(`---- Compile ${this.compileCounter} ----`);
    });
    // compile.hooks.compile.tap('DonePlugin', (params) => {
    //   console.info('---- Compile ----');
    // });
    compiler.hooks.afterCompile.tap("DonePlugin", () => {
      console.timeEnd(`---- Compile ${this.compileCounter} ----`);
      this.compileCounter--;
    });
    compiler.hooks.thisCompilation.tap("DonePlugin", (thisCompilation) => {
      console.info("---- ThisCompilation ----");
    });
    compiler.hooks.compilation.tap("DonePlugin", (compilation) => {
      console.info("---- Compilation ----");
    });
    compiler.hooks.afterDone.tap("DonePlugin", () => {
      console.info("\u001B[42mFin.\u001B[0m");
    });
  }
}

export default DepLayerPlugin;
